import pymysql
from flask import Flask, request, jsonify, session


from flask_script import Manager
from flask_cors import CORS


import os


class Application(Flask):

    def __init__(self, import_name, template_folder=None, root_path=None):
        super(Application, self).__init__(import_name, template_folder=template_folder, root_path=root_path,
                                          static_folder=None)
        self.config.from_pyfile('server/config/base_setting.py')
        self.config.from_pyfile('server/config/local_setting.py')

        # db.init_app(self)


# os.getcwd() --- 获取根目录
# super().__init__() --- 继承父类的方法

# 数据库连接

# 后端服务器
app = Application(__name__, template_folder=os.getcwd() + "/web/templates/", root_path=os.getcwd())
app.secrect = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

CORS(app)  # 解决跨域问题
manager = Manager(app)

'''
函数模板
'''
# from web.common.libs.UrlManager import UrlManager
#
# app.add_template_global(UrlManager.buildStaticUrl, 'buildStaticUrl')
# app.add_template_global(UrlManager.buildUrl, 'buildUrl')
# app.add_template_global(UrlManager.buildImageUrl, 'buildImageUrl')


if __name__ == '__main__':
    # app.run(host='0.0.0.0', port=8899)

    print(777)
    manager.run()
    db.close()
    print('over')
